from PyQt5 import QtWidgets
from PyQt5 import QtGui
import sys

class QRadioButtonTest(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super(QRadioButtonTest, self).__init__(parent)

        self.setWindowTitle("Radio Buttons Test")

        self.radio_btn1 = QtWidgets.QRadioButton("Button1")
        self.radio_btn1.setChecked(True)
        self.radio_btn1.toggled.connect(lambda : self.btn_state(self.radio_btn1))

        self.radio_btn2 = QtWidgets.QRadioButton("Button2")
        self.radio_btn2.toggled.connect(lambda : self.btn_state(self.radio_btn2))

        _h_box_layout = QtWidgets.QHBoxLayout()
        _h_box_layout.addWidget(self.radio_btn1)
        _h_box_layout.addWidget(self.radio_btn2)

        self.setLayout(_h_box_layout)

    def btn_state(self, btn):
        _btn_name = btn.text()
        _check_state = None

        if btn.isChecked():
            _check_state = "Checked"
        else:
            _check_state = "unChecked"
        
        print(_btn_name, " ", _check_state)

    


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)

    win = QRadioButtonTest()
    win.show()

    sys.exit(app.exec_())